<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>AjaxDemo1</title>
</head>
<body>
<button id="btn" onclick="">发送请求</button>


<script type="text/javascript">
    function ajaxClick() {
        var xmlhttp;
        //1.创建对象
        xmlhttp = new XMLHttpRequest();

        //2.发送请求

        //2.1设置请求方法与url
        xmlhttp.open("GET", "http://localhost:8080/Ajax_01/ajaxServlet", true);

        //2.2发送请求
        xmlhttp.send();

        //3.获取响应
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

                alert(xmlhttp.responseText);
            }
        }
    }

</script>


</body>
</html>